﻿// =================================================================== 
// 项目说明
//====================================================================
// liucx。@Copy Right 2019
// 文件： GroupComment.cs
// 项目名称：斑马车务
// 创建时间：2019/10/12
// 负责人：liucx
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using Dapper.Extensions;
using YouWei.Infrastructure.Entity;
using YouWei.Infrastructure.Repository;
using YouWei.Infrastructure.Models;

namespace YouWei.Infrastructure.Service
{

    /// <summary>
    ///群空间内容
    /// </summary>
    public class GroupCommentService
    {
        protected GroupCommentRepository repository;

        public GroupCommentService()
        {
            repository = new GroupCommentRepository();
        }

        #region 增删改查

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(GroupComment entity) { return repository.Insert(entity); }

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(List<GroupComment> entitys) { return repository.Insert(entitys); }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Update(GroupComment entity) { return repository.Update(entity); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Delete(GroupComment entity) { return repository.Delete(entity); }

        /// <summary>
        /// 删除所有
        /// </summary>
        /// <returns></returns>
        public bool DeleteAll() { return repository.DeleteAll(); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public bool Delete(int primaryKey) { return repository.Delete(primaryKey); }

        /// <summary>
        /// 查询单个实体
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public GroupComment SingleOrDefault(object primaryKey) { return repository.SingleOrDefault(primaryKey); }


        /// <summary>
        /// 查询单个实体,如果存在多条则引发异常
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public GroupComment Single(object primaryKey) { return repository.Single(primaryKey); }

        /// <summary>
        /// 查询所有
        /// </summary>
        /// <returns></returns>
        public List<GroupComment> QueryAll()
        {
            return repository.QueryAll();
        }

        #endregion

        /// <summary>
        /// 分页，创建日期倒叙排列
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="userId"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public Page<GroupCommentDto> Pages(int pageIndex, int pageSize, string openID, int Section, int isHot, int carGroupId, string orderName, string orderAsc = "ASC")
        {
            return repository.Pages(pageIndex, pageSize, openID, Section, isHot,carGroupId, orderName, orderAsc);
        }
        /// <summary>
        /// 分页，创建日期倒叙排列
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public Page<GroupComment> Pages(int pageIndex, int pageSize, GroupCommentSearchModel model)
        {
            return repository.Pages(pageIndex, pageSize, model);
        }
        /// <summary>
        /// 根据ID获取详细信息，包含detail
        /// </summary>
        /// <param name="CommentId"></param>
        /// <returns></returns>

        public GroupCommentDto GetGroupCommentInfoById(int GroupCommentId)
        {
            return repository.GetGroupCommentInfoById(GroupCommentId);
        }

        /// <summary>
        /// 添加点赞
        /// </summary>
        /// <param name="CommentId"></param>
        public void AddPraiseCount(int CommentId)
        {
            repository.AddPraiseCount(CommentId);
        }

        /// <summary>
        /// 添加浏览
        /// </summary>
        /// <param name="CommentId"></param>
        public void AddPageViews(int CommentId)
        {
            repository.AddPageViews(CommentId);
        }

        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="CommentId"></param>
        public void AddEvaluateCount(int CommentId)
        {
            repository.AddEvaluateCount(CommentId);
        }
    }

}